<?php 

$systemPrefix = 'ims_';
$companyPrefix = 'hwl_';
$modulePrefix = 'active_';

$sql = "
    
    CREATE TABLE IF NOT EXISTS `{$systemPrefix}{$companyPrefix}users` (
      `id` int(11) NOT NULL,
      `uid` varchar(32) NOT NULL COMMENT '微信唯一标志',
      `name` varchar(16) NOT NULL COMMENT '用户昵称',
      `avatar` varchar(32) NOT NULL COMMENT '头像地址',
      `create_time` int(11) NOT NULL COMMENT '加入时间',
      `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户类型：1新用户（默认） 2老用户  3推广员',
      `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户状态，一般为1。2为禁用'
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='nmyx:微信用户表，所有模块可涉及的用户为全体';

    CREATE TABLE IF NOT EXISTS `{$systemPrefix}{$companyPrefix}{$modulePrefix}cate` ( `id` INT NOT NULL AUTO_INCREMENT , `title` VARCHAR(15) NOT NULL , `sort` INT NOT NULL DEFAULT '0' , `create_time` INT NOT NULL , PRIMARY KEY (`id`)) ENGINE = MyISAM COMMENT = 'nmyx:活动分类';
  
    CREATE TABLE `we7`.`ims_hwl_service_user` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR(20) NOT NULL , `wechat_qrcode` VARCHAR(50) NOT NULL COMMENT '微信二维码链接地址' , `mobile` VARCHAR(13) NOT NULL COMMENT '手机号' , `avatar` VARCHAR(50) NOT NULL COMMENT '头像' , `create_time` INT NOT NULL , PRIMARY KEY (`id`)) ENGINE = MyISAM COMMENT = '客服';

    CREATE TABLE `we7`.`ims_hwl_active` ( `id` INT NOT NULL , `status` TINYINT NOT NULL DEFAULT '1' COMMENT '1正在进行 2关闭' , `active_cate_id` INT NOT NULL COMMENT '活动类别ID' , `title` VARCHAR(100) NOT NULL COMMENT '活动标题' , `cover` VARCHAR(100) NOT NULL COMMENT '活动封面图' , `price` DOUBLE(10,2) NOT NULL COMMENT '参与价格' , `min_get` DOUBLE(10,2) NOT NULL DEFAULT '0' COMMENT '推荐返利最小值' , `max_get` DOUBLE(10,2) NOT NULL DEFAULT '0' COMMENT '推荐返利最大值' , `service_user_id` INT NOT NULL COMMENT '客服ID' , `content` TEXT NOT NULL COMMENT '活动描述' , `end_time` INT NOT NULL COMMENT '结束时间' , `second_title` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '活动小标题' , `planner` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '策划人' , `inst` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '机构地区' , `school` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '学校名称' , `consignee` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货人姓名' , `consignee_mobile` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '收货人联系电话' , `consignee_addr` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '收货地址' , `goods` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '货' , `service_tel` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '客服电话' , `bgm` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '背景音乐' ) ENGINE = MyISAM;



";

$res = pdo_run($sql);

if(!$res) {
  return ;
}



$modulesInsertData = [
  'name' => 'active',
  'title' => '活动信息管理',
  'settings' => 1,
  'isrulefields' => 1,
  'issystem' => 1,
  'target' => 1,
  'iscard' => 1,
  'wxapp_support' => 2,
  'app_support' => 1,
  'welcome_support' => 1,
  'oauth_type' => 1,
  'webapp_support' => 1,
  'phoneapp_support' => 2
];

pdo_insert('modules', $modulesInsertData);


$modulesBindingsInsertDataTpl = [
  'module' => 'active',
  'entry' => 'menu',
  'title' => null,
  'do' => null,
  'state' => 1,
  'direct' => 1,
  'displayorder' => 100
];


$modulesBindingsInsertDataTpl['title'] = '全部活动';
$modulesBindingsInsertDataTpl['do'] = 'allActive';
$modulesBindingsInsertDataTpl['displayorder'] = 100;
pdo_insert('modules_bindings', $modulesBindingsInsertDataTpl);

$modulesBindingsInsertDataTpl['title'] = '全部分类';
$modulesBindingsInsertDataTpl['do'] = 'activeCate';
$modulesBindingsInsertDataTpl['displayorder'] = 99;
pdo_insert('modules_bindings', $modulesBindingsInsertDataTpl);

